package day4zy;

import java.awt.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Xierushijian {
    public static void main(String[] args) throws IOException {
        while (true){
            System.out.println("请输入文字：");
            Scanner in = new Scanner(System.in);
            String a = in.next();
            if (a.equals("quit")){
                System.exit(0);
            }else {
                File f = new File("C:\\Users\\徐恩德\\Desktop\\前端\\新建文件夹2");
                if (f.exists() == false) {
                    boolean m = f.mkdirs();
                    System.out.println(m);
                }
                File f2=new File("C:\\Users\\徐恩德\\Desktop\\前端\\新建文件夹2\\day4zy.txt");
                try {
                    f2.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                FileOutputStream fout=new FileOutputStream("C:\\Users\\徐恩德\\Desktop\\前端\\新建文件夹2\\day4zy.txt",true);
                Date date=new Date();
                SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
                fout.write(df.format(date).getBytes());
                fout.write(' ');
                fout.write(a.getBytes());
                fout.write('\n');
            }
            }
        }

        }


